package com.quanyan.api.enums;

/**
 * Created by wmb on 2016/6/3.
 */
public enum Currency {
    RMB(0,"人民币"),

    EGGS(1,"鸟蛋"),

    SHELL(2,"鸟壳" ),;

    private Integer id;




    private String name;


    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    Currency(Integer id, String name) {
        this.id = id;

        this.name = name;

    }

    public static Byte getIdByName(String name) {
        if(null==name){
            return null;
        }
        for(Currency tmp: Currency.values()) {
            if(tmp.toString() .equals(name)) {
                return tmp.id.byteValue();
            }
        }
        return null;
    }

    public static String getNameById(Byte id) {
        if(null==id){
            return null;
        }
        for(Currency tmp: Currency.values()) {
            if(tmp.id.byteValue() == id.byteValue()) {
                return tmp.getName();
            }
        }
        return null;
    }
}
